package net.meblabs.bookapp.service;

import java.util.List;

import net.meblabs.bookapp.data.dao.AuthorDaoImpl;
import net.meblabs.bookapp.data.model.Author;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;

@Service
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class AuthorService {

	@Autowired
	private AuthorDaoImpl authorDaoImpl;

	private List<Author> authors;

	public List<Author> getAuthors() {
		if (authors == null) {
			authors = authorDaoImpl.find();
		}
		return authors;
	}
}